package com.emc.atmos.test;

import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder;

import org.apache.log4j.Logger;

public class AtmosResponseGenerator {
	private static Logger log = Logger.getLogger(AtmosResponseGenerator.class);
	
	/*
	 * HTTP/1.1 201 Created
			Date: Wed, 09 Mar 2011 11:37:54 GMT
			Server: Apache
			x-emc-policy: default
			x-emc-delta: 105836
			                                    Creating an object 51
			REST API Reference
           location:
           /rest/objects/4d773b6ca10574f404d773bd3bedfc04d776693243b8
           x-emc-meta: user.maui.expirationEnable=NONE,
           user.maui.expirationEnd=NONE,
           user.maui.retentionEnable=false,
           user.maui.retentionStart=2012-04-10T12:38:56Z,
           user.maui.retentionEnd=2014-06-12T14:40:58Z
           Content-Length: 0
           Connection: close
           Content-Type: text/plain; charset=UTF-8
	 */
	
	
	public Response genCreateObjectResponse(String local_oid) {
		
		// create HTTP 201 response
		ResponseBuilder rb = Response.status(201);
		
		rb.status(201);
		
		//Date
		rb.header("Date", "Wed, 09 Mar 2011 11:37:54 GMT");
		
		//Server
		rb.header("Server", "Apache");
		
		//x-emc-policy
		rb.header("x-emc-policy", "default");
		
		//x-emc-delta
		rb.header("x-emc-delta", "105836");
		
		// location
		rb.header("location", "/rest/objects/" + local_oid);
		
		
		// x-emc-meta
		rb.header("x-emc-meta", "user.maui.expirationEnable=NONE, user.maui.expirationEnd=NONE," +
					" user.maui.retentionEnable=false, user.maui.retentionStart=2012-04-10T12:38:56Z," +
					" user.maui.retentionEnd=2014-06-12T14:40:58Z");
		
		// content-length
		rb.header("Content-Length", "0");
		
		// Connection
		rb.header("Connection", "close");
		
		// Content-Type
		rb.header("Content-Type", "text/plain; charset=UTF-8");
		
		
		//log.info("response headers: " + rb.build().getMetadata());
		
		return rb.build();
	}

}
